//
//  ContentTableViewCell.m
//  GiftSpeak
//
//  Created by dllo on 15/10/7.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ContentViewCell.h"
#import "UIImageView+WebCache.h"
#import "ContentModel.h"

@interface ContentViewCell ()
@property(nonatomic,retain)UILabel *contentLabel;
@property(nonatomic,retain)UIImageView *profile_Image;
@property(nonatomic,retain)UILabel *usernameLabel;
@end
@implementation ContentViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
-(void)createView
{
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    self.profile_Image = [[UIImageView alloc]initWithFrame:CGRectMake(10*OffWidth, 10*OffHeight, width/8, width/8)];
    [self.contentView addSubview:self.profile_Image];
    self.profile_Image.layer.cornerRadius = width/8/2;
    self.profile_Image.clipsToBounds = YES;
    [self.profile_Image release];
    
    
    self.usernameLabel = [[UILabel alloc]initWithFrame:CGRectMake(width/8 + 30*OffWidth, 10*OffHeight, width-width/8 - 50*OffWidth, 30*OffHeight)];
    [self.contentView addSubview:self.usernameLabel];
    [self.usernameLabel release];
    
    
    self.contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(width/8 + 30*OffWidth, 50*OffHeight,width*4/5 - 20*OffWidth, 30*OffHeight)];
    [self.contentView addSubview:self.contentLabel];
    [self.contentLabel release];
   
}

-(void)sendModel:(ContentModel *)model
{
    self.model = model;
    self.usernameLabel.text = [model.user objectForKey:@"username"];
    [self.profile_Image sd_setImageWithURL:[NSURL URLWithString:[model.user objectForKey:@"profile_image"]] placeholderImage:[UIImage imageNamed:@"ZhanWei.jpg"]];
    self.contentLabel.text = model.content;
}
@end
